﻿using System;

namespace FuzzScript
{
    public abstract class FuzzyHedge :Node
    {
        internal FuzzyHedge()
        {
            m_SiblingNodes.Add(null);
        }

        internal INode HedgedExpression
        {
            get { return m_SiblingNodes[0]; }
        }

        public override double Execute()
        {
            throw new NotImplementedException();
        }

        public override void AddSibling(INode p_SiblingNode)
        {
            m_SiblingNodes[0] = p_SiblingNode;
        }

        public override string Generate()
        {
            throw new NotImplementedException();
        }
    }

    internal class HedgeNot : FuzzyHedge
    {
        public override string ToString()
        {
            return "NOT( " + HedgedExpression.ToString() + " )";
        }

        public override double Execute()
        {
            return (1 - HedgedExpression.Execute());
        }

        public override string Generate()
        {
            return "(1 - "+HedgedExpression.Generate()+")";
        }
    }

    internal class HedgeVery : FuzzyHedge
    {
        public override string ToString()
        {
            return "VERY( " + HedgedExpression.ToString() + " )";
        }

        public override double Execute()
        {
            return Math.Pow(HedgedExpression.Execute(),2);
        }

        public override string Generate()
        {
            return "Math.Pow("+HedgedExpression.Generate()+", 2)";
        }
    }
}
